#if defined(_WIN32) || defined(_WIN64)
#include <windows.h>
#endif 
#include "glh_glut.h"

namespace glh {
std::list<glut_interactor*> glh_data::interactors;
bool glh_data::propagate;

void glut_display_function()
{
  glh_data::propagate = true;
  for(std::list<glut_interactor *>::iterator it=glh_data::interactors.begin(); it != glh_data::interactors.end() && glh_data::propagate; it++)
    (*it)->display();
}

void glut_idle_function()
{
  glh_data::propagate = true;
  for(std::list<glut_interactor *>::iterator it=glh_data::interactors.begin(); it != glh_data::interactors.end() && glh_data::propagate; it++)
    (*it)->idle();
}

void glut_keyboard_function(unsigned char k, int x, int y)
{
  glh_data::propagate = true;
  for(std::list<glut_interactor *>::iterator it=glh_data::interactors.begin(); it != glh_data::interactors.end() && glh_data::propagate; it++)
    (*it)->keyboard(k, x, y);
}

void glut_menu_status_function(int status, int x, int y)
{
  glh_data::propagate = true;
  for(std::list<glut_interactor *>::iterator it=glh_data::interactors.begin(); it != glh_data::interactors.end() && glh_data::propagate; it++)
    (*it)->menu_status(status, x, y);
}

void glut_motion_function(int x, int y)
{
  glh_data::propagate = true;
  for(std::list<glut_interactor *>::iterator it=glh_data::interactors.begin(); it != glh_data::interactors.end() && glh_data::propagate; it++)
    (*it)->motion(x, y);
}

void glut_mouse_function(int button, int state, int x, int y)
{
  glh_data::propagate = true;
  for(std::list<glut_interactor *>::iterator it=glh_data::interactors.begin(); it != glh_data::interactors.end() && glh_data::propagate; it++)
    (*it)->mouse(button, state, x, y);
}

void glut_passive_motion_function(int x, int y)
{
  glh_data::propagate = true;
  for(std::list<glut_interactor *>::iterator it=glh_data::interactors.begin(); it != glh_data::interactors.end() && glh_data::propagate; it++)
    (*it)->passive_motion(x, y);
}

void glut_reshape_function(int w, int h)
{
  glh_data::propagate = true;
  for(std::list<glut_interactor *>::iterator it=glh_data::interactors.begin(); it != glh_data::interactors.end() && glh_data::propagate; it++)
    (*it)->reshape(w,h);
}

void glut_special_function(int k, int x, int y)
{
  glh_data::propagate = true;
  for(std::list<glut_interactor *>::iterator it=glh_data::interactors.begin(); it != glh_data::interactors.end() && glh_data::propagate; it++)
    (*it)->special(k, x, y);
}

void glut_timer_function(int v)
{
  glh_data::propagate = true;
  for(std::list<glut_interactor *>::iterator it=glh_data::interactors.begin(); it != glh_data::interactors.end() && glh_data::propagate; it++)
    (*it)->timer(v);
}

void glut_visibility_function(int v)
{
  glh_data::propagate = true;
  for(std::list<glut_interactor *>::iterator it=glh_data::interactors.begin(); it != glh_data::interactors.end() && glh_data::propagate; it++)
    (*it)->visibility(v);
}

} // namespace glh
